<template>
	<view>
		<an-nav-bar :title="`设置${type == 1 ? '个人':'门店' }介绍`">
			<template :slot="'right'">
				<view style="color: #fff;" @click="save">保存</view>
			</template>
		</an-nav-bar>
		<view class="content">
			<view class="tips">{{type == 1 ? '个人':'门店' }}介绍
				<text>（最少30字，最多200字，必填项）</text>
			</view>
			<view class="text">
				<textarea v-model="text" :placeholder="`请填写您的${type == 1 ? '个人':'门店' }介绍`" :maxlength="200"></textarea>
				<i>{{text.length}}/200</i>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				text: "",
				type: 1
			};
		},
		onLoad(option) {
			this.type = option.type
		},
		methods: {
			save() {
				// 返回上一页并刷新数据方法
				let pages = getCurrentPages() // 获取页面栈
				let prePage = pages[pages.length - 2] //获取上一页
				prePage.$vm.technicianForm.selfIntroduction = this.text;

				// 返回上一页 delta返回的页面数 如果delta大于现有页面数，则返回首页
				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #fff;
	}

	.content {
		padding: 0 20rpx;

		.text {
			width: 710rpx;
			height: 460rpx;
			background: #f8f8f8;
			border-radius: 10rpx;
			padding: 20rpx;
			box-sizing: border-box;
			position: relative;

			i {
				position: absolute;
				right: 20rpx;
				bottom: 20rpx;
				color: #999;
				font-size: 28rpx;
			}

			textarea {
				font-size: 30rpx;
				color: #333;
				width: 100%;
				height: 100%;
			}
		}

		.tips {
			padding: 36rpx 0 22rpx 10rpx;
			color: #666;
			font-size: 30rpx;

			text {
				color: #999;
				font-size: 14px;
			}
		}
	}
</style>
